#ifndef _X6_H_INCLUDED_
#define _X6_H_INCLUDED_
#include <string.h>
#include <string>
#include <map>
#include <memory>
using std::string;
using std::map;

//const int MAX_RECV_SIZE = 1024;
//const int DEFAULT_BUFFER_SIZE = 4096;
//使用有限状态机实现的，我寄几制定的X6协议
/*
request-resource:<resource_name>(\r\n)
content-length:<length>(\r\n)
data:{"user_id": 1, "user_code": XXXXXXXXXXXbase64, "forward_id": XXXXXX}(\r\n)
*/

class X6
{
private:
    string keywords = "request-resource: $content-length: $data: $"; 
    const int POS_OF_1 = 17;
    const int POS_OF_2 = 34;
    const int POS_OF_3 = 41;
    int status = 0;
    bool is_complete = false;
    bool msgParser(const char* buffer, int length);
/*----------------------------------------------------*/
    
public:
    map<string, string> dataSet;
    inline X6()
    {
        dataSet["request-resource"] = string();
        dataSet["content-length"] = string();
        dataSet["data"] = string();
    }
    bool parser(const char* buffer, int recv_len);
    bool isComplete();
    void reset();
    ~X6() = default;
};



#endif